 //usage:
 //   zcc +embedded ns16450.o testprogram.c -otestprogram.bin -lim2 -lembedded_clib2
 
#include <stdlib.h>
#include <im2.h>
#include "ns16450.h"

#define INT_DISABLE()   asm("di")
#define INT_ENABLE()    asm("ei")

#define IOPORT1_BASE		0x0010
#define IOPORT0_BASE		0x0020
#define KEYBOARD_BASE		0x0030

void main()
{
	outp(IOPORT1_BASE, 0x55);
	outp(IOPORT0_BASE, 0xAA);
	
     
  /* convert 24 MHz to 16*baudrate
         9600 : 0x9c
       115200 : 0x0d
  */
  init_uart(0x00, 0x0d); 

  outp(UART_BASE + THR, 'T');
  outp(UART_BASE + THR, 'e');
  outp(UART_BASE + THR, 's');
  outp(UART_BASE + THR, 't');
 
  for (;;)
  {
    char UARTsr = 0;
    
    
    UARTsr = inp(UART_BASE + LSR);
    if (UARTsr & 0x01)
    {
      char ch;
      ch = inp(UART_BASE + RBR);
      outp(UART_BASE + THR, ch + 1);
    }
  }
}


